import java.awt.Color;


public class Dot {	
	// name of what the dot represents; the mousover title
	public String item;
	// the color of the dot
	public Color color;
	
	// radius of dot
	public int radius = 5;
	
	//////////////////
	// Polar Coords //
	//////////////////
	// direction angle to the dot from the center (radians)
	public double dir;
	// magnitude, how far away from the center in the angle specified by dir
	public double mag;
	
	//////////////////////
	// Cartesian Coords //
	//////////////////////
	public double x;
	public double y;
	
	public Dot(String title, Color myColor){
		item = title;
		color = myColor;
	}
	
	public Dot(String title){
		item = title;
		color = new Color((float)Math.random(), (float)Math.random(), (float)Math.random());
	}
	
	public void updateXY(){
		x = mag*Math.cos(dir)+(Wikimap.WIDTH/2);
		y = (Wikimap.HEIGHT/2)-mag*Math.sin(dir);
	}
	
	public void updatePolar(){
		dir = getDir(y, x);
		mag = Math.hypot(x-Wikimap.WIDTH/2, y-Wikimap.HEIGHT/2);
	}
	
	public static double getDir(double ynum, double xnum){
		if(ynum<Wikimap.HEIGHT/2){
			return Math.atan2(Wikimap.HEIGHT/2-ynum, xnum-Wikimap.WIDTH/2);
		} else{
			return Math.PI+Math.atan2(ynum-Wikimap.HEIGHT/2, Wikimap.WIDTH/2-xnum);
		}
	}
	
	public boolean isOver(int xcheck, int ycheck){
		if(Math.hypot(xcheck-this.x, ycheck-this.y)<this.radius){
			return true;
		} else{
			return false;
		}
	}
}